@extends("la.layouts.app")

@section("contentheader_title", "推广域名管理")
@section("contentheader_description", "推广域名管理")
@section("section", "推广域名管理")
@section("sub_section", "Listing")
@section("htmlheader_title", "推广域名管理")

@section("headerElems")
    <a href="/admin/domain/0"><button class="btn btn-success btn-sm pull-right">添加子域名</button></a>
@endsection

@section("main-content")

    @if (count($errors) > 0)
        <div class="alert alert-danger">
            <ul>
                @foreach ($errors->all() as $error)
                    <li>{{ $error }}</li>
                @endforeach
            </ul>
        </div>
    @endif

    <div class="box box-success">
        <div class="box-body">
            <div id="example1_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                <div class="row">
                    <div class="col-sm-12">
                        <table id="example1" class="table table-bordered dataTable no-footer" role="grid"
                               aria-describedby="example1_info">
                            <thead>
                            <tr class="success" role="row">
                                <th class="" tabindex="0">
                                    id
                                </th>
                                <th class="" tabindex="0">
                                    域名
                                </th>
                                <th class="" tabindex="0">
                                    状态
                                </th>
                                <th class="" tabindex="0">
                                    操作
                                </th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach($domains as $domain)
                                <tr role="row" class="odd">
                                    <td class="_1">{{ $domain->id }}</td>
                                    <td>{{ $domain->domain }}</td>
                                    <td>{{ $domain->status_word }}</td>
                                    <td>
                                        <a href="/admin/domain/{{ $domain->id }}" class="btn btn-warning btn-xs" style="display:inline;padding:2px 5px 3px 5px;"><i class="fa fa-edit"></i></a>
                                        <form method="POST" action="/admin/domain/{{ $domain->id }}" accept-charset="UTF-8" style="display:inline">
                                            <input name="_method" type="hidden" value="DELETE">
                                            <input name="_token" type="hidden" value="{{ csrf_token() }}">
                                            <button class="btn btn-danger btn-xs" type="submit">
                                                <i class="fa fa-times"></i>
                                            </button>
                                        </form>
                                        @if(0 == $domain->status)
                                            <form method="POST" action="/admin/domain/{{ $domain->id }}/enable" accept-charset="UTF-8" style="display:inline">
                                                <input name="_token" type="hidden" value="{{ csrf_token() }}">
                                                <button class="btn btn-success btn-xs" type="submit">
                                                    <i class="fa fa-arrow-up"></i>
                                                </button>
                                            </form>
                                        @endif
                                        @if(1 == $domain->status)
                                            <form method="POST" action="/admin/domain/{{ $domain->id }}/disable" accept-charset="UTF-8" style="display:inline">
                                                <input name="_token" type="hidden" value="{{ csrf_token() }}">
                                                <button class="btn btn-success btn-xs" type="submit">
                                                    <i class="fa fa-arrow-down"></i>
                                                </button>
                                            </form>
                                        @endif

                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-5">
                        <div class="dataTables_info" id="example1_info" role="status" aria-live="polite">
                            一共{{ $domains->total() }}个
                        </div>
                    </div>
                    <div class="col-sm-7" style="padding-right: 20px;">
                        <div class="dataTables_paginate paging_simple_numbers" id="example1_paginate">
                            {!! $domains->render() !!}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection

@push('styles')
    <link rel="stylesheet" type="text/css" href="{{ asset('la-assets/plugins/datatables/datatables.min.css') }}"/>
@endpush

@push('scripts')
    <script src="{{ asset('la-assets/plugins/datatables/datatables.min.js') }}"></script>
    <!--
    <script>
        $(function () {
            $("#example1").DataTable({
                processing: true,
                serverSide: true,
                ajax: "{{ url(config('laraadmin.adminRoute') . '/organization_dt_ajax') }}",
                language: {
                    lengthMenu: "_MENU_",
                    search: "_INPUT_",
                    searchPlaceholder: "Search"
                },
                {{--@if($show_actions)--}}
    {{--columnDefs: [ { orderable: false, targets: [-1] }],--}}
    {{--@endif--}}
            });
            $("#organization-add-form").validate({

            });
        });
    </script>
    -->
@endpush